package com.example.project.webControlleer;

import com.example.project.dao.WalletHistroyDAO;
import com.example.project.pojo.User;
import com.example.project.pojo.WalletHistory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("web")
public class WebHistoryController {
    @RequestMapping("history")
    public void history(Model model, HttpSession session) {
        List<WalletHistory> walletHistoryList;
        User user = (User) session.getAttribute("user");
        WalletHistroyDAO walletHistroyDAO =new WalletHistroyDAO();
       walletHistoryList= walletHistroyDAO.findChargeHistoryByUserID(user);
       walletHistoryList.addAll(walletHistroyDAO.findParkingHistoryByUserID(user));
       model.addAttribute("walletHistoryList",walletHistoryList);
    }
}
